package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.ActivityMapper;
import com.xxx.modules.entity.Activity;
import com.xxx.modules.service.ActivityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * activity
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@Service
public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> implements ActivityService {

    @Autowired
    private ActivityMapper activityMapper;


    @Override
    public PageInfo<Activity> selectActivityInfo(Activity activity, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Activity> wrapper = new QueryWrapper<>();
        List<Activity> data = activityMapper.selectListInfo(activity);
        return new PageInfo<>(data);
    }

    @Override
    public void saveActivityInfo(Activity activity) {
        activity.setCreateTime(TimeUtil.getCurrentTime());
        activityMapper.insert(activity);
    }

    @Override
    public void updateActivityInfo(Activity activity) {
        activityMapper.updateById(activity);
    }

    @Override
    public void delActivityInfo(Integer id) {
        activityMapper.deleteById(id);
    }

    @Override
    public void delBatchActivityInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        activityMapper.deleteBatchIds(list);
    }


}